package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation  implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        System.out.println("请输入你要查找的图书书名");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        int i =0;
        for(i =0;i<bookList.getUsedSize();++i) {
            Book book = bookList.getPos(i);
            if(bookList.getPos(i).bookName.equals(name)) {
                System.out.println("查找图书成功~~~"+"~~~图书信息如下：");
                System.out.println(book);
                return;
            }
        }
        if(i==bookList.getUsedSize()){
            System.out.println("没有找到这本书");
        }
    }
}
